package com.wfuhui.modules.oms.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wfuhui.common.utils.PageUtils;
import com.wfuhui.common.utils.Query;
import com.wfuhui.common.utils.R;
import com.wfuhui.modules.oms.entity.OrderShipmentEntity;
import com.wfuhui.modules.oms.service.OrderShipmentService;




/**
 * 订单配送表
 *
 */
@RestController
@RequestMapping("ordershipment")
public class OrderShipmentController {
	@Autowired
	private OrderShipmentService orderShipmentService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("ordershipment:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<OrderShipmentEntity> orderShipmentList = orderShipmentService.queryList(query);
		int total = orderShipmentService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(orderShipmentList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("ordershipment:info")
	public R info(@PathVariable("id") Integer id){
		OrderShipmentEntity orderShipment = orderShipmentService.queryObject(id);
		
		return R.ok().put("orderShipment", orderShipment);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("ordershipment:save")
	public R save(@RequestBody OrderShipmentEntity orderShipment){
		orderShipmentService.save(orderShipment);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("ordershipment:update")
	public R update(@RequestBody OrderShipmentEntity orderShipment){
		orderShipmentService.update(orderShipment);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("ordershipment:delete")
	public R delete(@RequestBody Integer[] ids){
		orderShipmentService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
